home *** CD-ROM | disk | FTP | other *** search
- Path: news.cuny.edu!apccu
- From: Paul Abrilla <APCCU@CUNYVM.CUNY.EDU>
- Newsgroups: comp.lang.c++
- Subject: help on syntax
- Date: Tue, 2 Jan 1996 22:27:28 EST
- Organization: City University of New York/University Computer Center
- Message-ID: <96002.222728APCCU@CUNYVM.CUNY.EDU>
- NNTP-Posting-Host: cunyvm.cuny.edu
- Disclaimer: Author bears full responsibility for this post
-
- Hi,
-
- I'm trying to run a simple program, but I'm getting a 'misplaced
- else' error everytime I compile it. However, when I tried to modify
- the program the if statement it ran perfectly fine. Can anyone please
- tell me what's going on. Program I is the original, and Program II
- is the modified version. Any help will be appreciated. Please send
- replies directly to my account. Thanks.
-
- PROGRAM I
-
- #include <iostream.h>
- void main()
- {
- int a, b, c;
- cout << "Please enter three numbers¢n";
- cout << "a: ";
- cin >> a;
- cout << "¢nb: ";
- cin >> b;
- cout << "¢nc: ";
- cin >> c;
-
- if (c = (a-b))
- cout << "a: ";
- cout << a;
- cout << " minus b: ";
- cout << b;
- cout << " quals c: ";
- cout << c << endl;
- else
- cout << "a-b does not equal c: " << endl;
-
- }
-
-
- PROGRAM II
-
- :
- :
- :
- if (c = (a-b))
- cout << "a: " << a << " minus b: " << b << " equals c: " << c;
- else
- cout << "a-b does not equal c: ";
- }
-
-
- -----------
- Paul
- email: apccu@cunyvm.cuny.edu
-